#pragma once
#include <windows.h>
#include <vector>
#include "physics.h"

struct View { double scale; double ox; double oy; };

struct Trail { std::vector<POINT> pts; COLORREF color; };

class RendererWin32 {
public:
    void init(HWND hwnd, int w, int h);
    void resize(int w, int h);
    void begin();
    void draw_body(const Body& b, const View& v, COLORREF c);
    void draw_trail(const Trail& t);
    void draw_text(int x, int y, const wchar_t* s);
    void end(HWND hwnd);
    int width() const { return W; }
    int height() const { return H; }
private:
    HDC mdc{}; HBITMAP bmp{}; void* pixels{}; int W{}; int H{};
};

inline POINT to_screen(const Vec2& p, const View& v){ return { (LONG)(p.x*v.scale + v.ox), (LONG)(p.y*v.scale + v.oy) }; }